﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LanDBom.Models.Procure
{
    public class Find_BOM_with_APBian
    {
        LDbaseEntities LD = new LDbaseEntities();
        public List<BOMini> find_BOM(string APP_bian)
        {

           var listBOM = LD.BOMini.Where(x => x.BOM2_bian == APP_bian).ToList();

            List<BOMini> listBOM2 = listBOM.GroupBy(d => new { d.BOM2_liao}).Select(a =>a.OrderBy(b => b.BOM2_Zhuang).ElementAt(0)).ToList();
            return listBOM2;

            
        }
        //public List<BOMini> find_BOM(string APP_bian)
        //{

        //    List<BOMini> listBOM = LD.BOMini.Where(x => x.BOM2_bian == APP_bian).ToList();

        //    List<BOMini> listBOM2 = listBOM.GroupBy(d => new { d.BOM2_liao }).Select(d => d.FirstOrDefault()).ToList();
        //    return listBOM2;


        //}
        public List<BOMini> find_BOMed(string APP_bian)
        {

            List<BOMini> listBOM = LD.BOMini.Where(x => x.BOM2_bian == APP_bian&&x.BOM2_chen=="Leve0").ToList();

            List<BOMini> listBOM2 = listBOM.GroupBy(d => new { d.BOM2_liao }).Select(a => a.OrderBy(b => b.BOM2_Zhuang).ElementAt(0)).ToList();
            return listBOM2;
        }

        public List<BOMini> find_BOMing(string aPP_bian)
        {
            List<BOMini> listBOM = LD.BOMini.Where(x => x.BOM2_bian == aPP_bian && x.BOM2_Jin != "禁用"&&x.BOM2_Lei=="外购").ToList();

            listBOM = listBOM.GroupBy(d => new { d.BOM2_wuLiu}).Select(a => a.OrderByDescending(b => b.BOM2_Zhuang).ElementAt(0)).ToList();
            return listBOM;
        }
    }
}